<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
<head>
    <title>待办事项表单</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.3/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
    <div class="container mt-4">
        <h2>${todo != null ? '编辑待办事项' : '新建待办事项'}</h2>
        
        <form action="${todo != null ? 'update' : 'insert'}" method="post">
            <c:if test="${todo != null}">
                <input type="hidden" name="id" value="${todo.id}" />
            </c:if>
            
            <div class="form-group">
                <label>标题</label>
                <input type="text" name="title" class="form-control" 
                       value="${todo.title}" required>
            </div>
            
            <div class="form-group">
                <label>描述</label>
                <textarea name="description" class="form-control" rows="3">${todo.description}</textarea>
            </div>
            
            <div class="form-group">
                <label>截止日期</label>
                <input type="datetime-local" name="dueDate" class="form-control" 
                       value="<fmt:formatDate value="${todo.dueDate}" pattern="yyyy-MM-dd'T'HH:mm"/>">
            </div>
            
<%--            <c:if test="${todo != null}">--%>
<%--                <div class="form-group">--%>
<%--                    <label>--%>
<%--                        <input type="checkbox" name="completed" ${todo.completed ? 'checked' : ''}>--%>
<%--                        已完成--%>
<%--                    </label>--%>
<%--                </div>--%>
<%--            </c:if>--%>
            
            <button type="submit" class="btn btn-primary">保存</button>
            <a href="${pageContext.request.contextPath}/todos/list" class="btn btn-secondary">返回</a>
        </form>
    </div>
</body>
</html> 